<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户管理</title>
#include("../jscss.html")
<script type="text/javascript">
	$(function(){
		//查询结果表格
		var grid = $('#data-grid');
		grid.datagrid({
			border:false,
			columns:[[
			    {field:'ck',checkbox:true},
			    {field:'network',title:'银行网点',width:180},
				{field:'ems',title:'邮政网点',width:180},
				{field:'bigPackage',title:'揽收大包',width:160,sortable : true},
				{field:'smallPackage',title:'揽收小包',width:160,sortable : true},
				{field:'emptyPackage',title:'退回空包',width:160,sortable : true},
				{field:'abnormalPackage',title:'异常数量(仅显示多包少包异常)',width:200,sortable : true},
			]],
			fit:true,
			pagination:true,
			rownumbers:true,
			url:'reportList',
			pageList:[10,20,30,50,100],
			pageSize:20,
			toolbar:'#tb',
			singleSelect:true,
			nowrap:false,
			striped:true,
			onLoadSuccess:function onLoadSuccess() {
		        $('#data-grid').datagrid('appendRow', {
		            network: '<span class="subtotal">合计</span>',
		            ems: '<span class="subtotal"></span>',
		            bigPackage: '<span class="subtotal">' + compute("bigPackage") + '</span>',
		            smallPackage: '<span class="subtotal">' + compute("smallPackage") + '</span>',
		            emptyPackage: '<span class="subtotal">' + compute("emptyPackage") + '</span>',
		            abnormalPackage: '<span class="subtotal">' + compute("abnormalPackage") + '</span>'
		        });
		    }
		});
		
		$('#search').click(function(){
			var jsonParam = $('#search-form').serializeJsonNotNull();
			grid.datagrid('load', jsonParam);
		});

	});
	$(function(){
		   var curr_time = new Date();
		   var strDate = curr_time.getFullYear()+"-";
		   strDate += curr_time.getMonth()+1+"-";
		   strDate += curr_time.getDate()+"-";
		   strDate += curr_time.getHours()+":";
		   strDate += curr_time.getMinutes()+":";
		   strDate += curr_time.getSeconds();
		   $("#date").datebox("setValue", strDate); 
		  });
    //指定列求和
    function compute(colName) {
        var rows = $('#data-grid').datagrid('getRows');
        var total = 0;
        for (var i = 0; i < rows.length; i++) {
            total += parseFloat(rows[i][colName]);
        }
        return total;
    }
    
	function check(){
		var title = $('input[name="excelTitle"]').val();
		var sDate = Date.parse($('#startDate').datebox('getValue'));
		var eDate = Date.parse($('#endDate').datebox('getValue'));
		var startDate = new Date(sDate);
		var endDate = new Date(eDate);
		if(title.replace(/(^\s*)|(\s*$)/g, "").length ==0 || eDate == null || sDate == null){
			$.messager.alert('提示',
					'信息不能为空'   
				);
			return false;	
		}else if(startDate.getMonth()!=endDate.getMonth() || startDate.getFullYear()!=endDate.getFullYear()){
			$.messager.alert('提示',
					'起始截至日期月份不一致'   
				);
			return false;
		}else if(startDate.getTime()>endDate.getTime()){
			$.messager.alert('提示',
					'起始日期晚于截至日期'   
				);
			return false;
		}else{
			return true;
		}
	}
</script>
</head>
<body>
	<table id="data-grid">
	</table>
	<div id="tb" style="padding: 5px; height: auto">
		<div>
			<form action="export" id="search-form" method="post">
			网点名称: <input class="easyui-textbox" type="text" name="network" style="width: 120px">
			日期: <input  id="date" class="easyui-datebox" type="text" name="searchDate" style="width: 120px">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="search">查询</a>
			<button class="easyui-linkbutton" iconCls="icon-print" type="submit">导出当月报表</button>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls='icon-save' onclick="$('#w').window('open')">动态导出报表</a>
			</form>
		</div>
	</div>
	<div id="w" class="easyui-window" title="上行数据报表导出" data-options="iconCls:'icon-save'" style="width:400px;height:200px;padding:5px;" closed="true">
		<div class="easyui-layout" data-options="fit:true">
			<form action="exportDynamic" method="post" id="export-form" onsubmit="return check()">
				文档标题: <input class="easyui-textbox" type="text" name="excelTitle" style="width: 120px">
				<br>
				起始日期: <input  id="startDate" class="easyui-datebox" type="text" name="startDate" style="width: 120px">
				<br>
				截至日期: <input  id="endDate" class="easyui-datebox" type="text" name="endDate" style="width: 120px">
				<br>
				<button class="easyui-linkbutton" iconCls="icon-print" type="submit">导出报表</button>
			</form>
		</div>
	</div>
</body>
</html>